@@ -318,3 +318,12 @@ $service-colors: ( |
||
| 318 | 318 |
color: yellow; |
| 319 | 319 |
text-decoration: underline; |
| 320 | 320 |
} |
| 321 |
+ |
|
| 322 |
+.glyphicon-flipped {
|
|
| 323 |
+ -ms-transform: translateZ(0); |
|
| 324 |
+ -webkit-transform: translateZ(0); |
|
| 325 |
+ transform: translateZ(0); |
|
| 326 |
+ -ms-transform: scaleX(-1); |
|
| 327 |
+ -webkit-transform: scaleX(-1); |
|
| 328 |
+ transform: scaleX(-1); |
|
| 329 |
+} |
@@ -57,4 +57,46 @@ module AgentHelper |
||
| 57 | 57 |
'maybe'.freeze |
| 58 | 58 |
end |
| 59 | 59 |
end |
| 60 |
+ |
|
| 61 |
+ def agent_type_icon(agent, agents) |
|
| 62 |
+ receiver_count = links_counter_cache(agents)[:links_as_receiver][agent.id] || 0 |
|
| 63 |
+ control_count = links_counter_cache(agents)[:control_links_as_controller][agent.id] || 0 |
|
| 64 |
+ source_count = links_counter_cache(agents)[:links_as_source][agent.id] || 0 |
|
| 65 |
+ |
|
| 66 |
+ if control_count > 0 && receiver_count > 0 |
|
| 67 |
+ content_tag('span') do
|
|
| 68 |
+ concat icon_tag('glyphicon-arrow-right')
|
|
| 69 |
+ concat tag('br')
|
|
| 70 |
+ concat icon_tag('glyphicon-new-window', class: 'glyphicon-flipped')
|
|
| 71 |
+ end |
|
| 72 |
+ elsif control_count > 0 && receiver_count == 0 |
|
| 73 |
+ icon_tag('glyphicon-new-window', class: 'glyphicon-flipped')
|
|
| 74 |
+ elsif receiver_count > 0 && source_count == 0 |
|
| 75 |
+ icon_tag('glyphicon-arrow-right')
|
|
| 76 |
+ elsif receiver_count == 0 && source_count > 0 |
|
| 77 |
+ icon_tag('glyphicon-arrow-left')
|
|
| 78 |
+ elsif receiver_count > 0 && source_count > 0 |
|
| 79 |
+ icon_tag('glyphicon-transfer')
|
|
| 80 |
+ else |
|
| 81 |
+ icon_tag('glyphicon-unchecked')
|
|
| 82 |
+ end |
|
| 83 |
+ end |
|
| 84 |
+ |
|
| 85 |
+ private |
|
| 86 |
+ |
|
| 87 |
+ def links_counter_cache(agents) |
|
| 88 |
+ @counter_cache ||= {}
|
|
| 89 |
+ @counter_cache[agents.__id__] ||= {}.tap do |cache|
|
|
| 90 |
+ agent_ids = agents.map(&:id) |
|
| 91 |
+ cache[:links_as_receiver] = Hash[Link.where(receiver_id: agent_ids) |
|
| 92 |
+ .group(:receiver_id) |
|
| 93 |
+ .pluck('receiver_id', 'count(receiver_id) as id')]
|
|
| 94 |
+ cache[:links_as_source] = Hash[Link.where(source_id: agent_ids) |
|
| 95 |
+ .group(:source_id) |
|
| 96 |
+ .pluck('source_id', 'count(source_id) as id')]
|
|
| 97 |
+ cache[:control_links_as_controller] = Hash[ControlLink.where(controller_id: agent_ids) |
|
| 98 |
+ .group(:controller_id) |
|
| 99 |
+ .pluck('controller_id', 'count(controller_id) as id')]
|
|
| 100 |
+ end |
|
| 101 |
+ end |
|
| 60 | 102 |
end |
@@ -1,6 +1,7 @@ |
||
| 1 | 1 |
<div class='table-responsive'> |
| 2 | 2 |
<table class='table table-striped'> |
| 3 | 3 |
<tr> |
| 4 |
+ <th></th> |
|
| 4 | 5 |
<th><%= sortable_column 'name', 'asc' %></th> |
| 5 | 6 |
<th><%= sortable_column 'created_at', 'desc', name: 'Age' %></th> |
| 6 | 7 |
<th>Schedule</th> |
@@ -15,6 +16,9 @@ |
||
| 15 | 16 |
<% @agents.each do |agent| %> |
| 16 | 17 |
<tr> |
| 17 | 18 |
<td class='<%= "agent-unavailable" if agent.unavailable? %>'> |
| 19 |
+ <%= agent_type_icon(agent, @agents) %> |
|
| 20 |
+ </td> |
|
| 21 |
+ <td class='<%= "agent-unavailable" if agent.unavailable? %>'> |
|
| 18 | 22 |
<%= link_to agent.name, agent_path(agent, return: (defined?(return_to) && return_to) || request.path) %> |
| 19 | 23 |
<br/> |
| 20 | 24 |
<span class='text-muted'><%= agent.short_type.titleize %></span> |